Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more order of operation comparisons #13

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nathanielnrn
Copy link

@nathanielnrn nathanielnrn commented Jul 11, 2022

As discussed with @rachitnigam
Previously all BinOps were grouped under a single precedence enum "Op."
Now, they are spread out and more fine grained. This should fix issues
regarding parentheses and order of operations.

Also, some formatting was affected

Fixes #12

Previously all BinOps were grouped under a single precedence enum "Op."
Now, they are spread out and more fine grained. This should fix issues
regarding parentheses and order of operations
Expr::IPath(
InstancePath::new(path),
Some(Rc::new(Expr::new_ref(index))),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a formatting change. In general, we try to only commit the required functional changes for a particular commit. Can you remove this?

use crate::util::pretty_print::{block, intersperse, PrettyHelper, PrettyPrint};
use crate::util::pretty_print::{
block, intersperse, PrettyHelper, PrettyPrint,
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change

.append(width.to_doc())
.brackets(),
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change

RcDoc::text(".")
.append(RcDoc::as_string(id))
.append(expr.to_doc().parens())
}),
},
),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change

pub fn intersperse<'a>(
iter: impl Iterator<Item = RcDoc<'a>>,
separator: RcDoc<'a>,
) -> RcDoc<'a> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting change

Decl::Param(
name.to_string(),
Expr::new_ulit_dec(32, &value.to_string()),
)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are formatting changes

Copy link
Collaborator

@rachitnigam rachitnigam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nathanielnrn Seems like you might've committed a bunch of formatting changes. Can you separate them into a different PR or remove them entirely? Once done, I can re-review.

This reverts commit 9649010.
@nathanielnrn
Copy link
Author

nathanielnrn commented Jul 12, 2022

@nathanielnrn Seems like you might've committed a bunch of formatting changes. Can you separate them into a different PR or remove them entirely? Once done, I can re-review.

Sorry about that.
@rachitnigam I reverted the formatting changes to all files without content-changes to them. But all of the the formatting changes in subset/pretty_print.rs were made through the rust-analyzers auto formatting with rustfmt. Is there a configuration I can use to properly match the formatting as is? I could revert rustfmt's changes manually if needed.

(P::Index, P::Not) => Ordering::Less,
(P::Index, _) => Ordering::Greater,

(P::Mul, P::Not) | (P::Mul, P::Index) => Ordering::Less,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this code was written, rust started supporting nested patterns so you can write something like:

(P::Mul, P::Not | P::Index)

Which might be easier to read

@rachitnigam
Copy link
Collaborator

yeah, seems like this project doesn't have a .rustfmt file which describes the default formatting rules which is why rustfmt did this. I'm okay with committing some of them.

@rachitnigam rachitnigam self-requested a review July 12, 2022 04:42
Copy link
Collaborator

@rachitnigam rachitnigam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small suggestion but otherwise looks good!

@nathanielnrn
Copy link
Author

Made things nested, checks still fail due to other files' formatting from what I can tell, but should be good I think.

@rachitnigam
Copy link
Collaborator

That's really weird. The commands run for the workflow are here: https://github.com/vegaluisjose/vast/blob/main/Makefile

Can you try running the rules in the Makefile and see if you can locally reproduce the errors? It might be the case that VSCode might be using a globally configured .rustfmt causing it to format things differently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Order of operations incorrect for addition and bit shift
2 participants